<template>
	<view>
		<view class="wid90 mar">
			<view class="hei20"></view>
			<view class="borRad40 dis disAl disJuC foSi25 hei60 coFFF mar foSi28" @click="fanhui()"
				style="background: linear-gradient(to right, #fb8480, #fa3f86);width: 240rpx;">返回首页</view>
			<view style="height: 20rpx;"></view>
			<view v-if="type != 3" class="mar-bott20 textCen fowe600 foSi30">{{title}}</view>
			<rich-text :selectable="true" :nodes="data" style="-webkit-user-select: text;-moz-user-select: text;-ms-user-select: text;user-select: text;"></rich-text>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				title: '',
				data:'',
				type: 1
			}
		},
		onLoad(options) {
			if(options.type == 1){
				this.id = options.id
				this.getGonggao()
			}else if(options.type == 2){
				this.id = options.id
				this.getList()
			}else if(options.type == 3){
				this.type = 3
				this.geiFankui()
			}
			
		},
		methods: {
			fanhui(){
				uni.navigateBack(1)
			},
			geiFankui(){
				var that = this
				uni.request({
					url: this.global.url+'api/zy/wechat_qun_info',
					method: 'POST',
					data: {},
					success: (res) => {
						let result = res.data
						if (result.code == 1) {
							console.log(result.data.title)
							uni.setNavigationBarTitle({
								title: '反馈'
							});
							var data = result.data
							data = data.replace(/<img/gi, "<img class='richImg'");
							that.data = data
						} else {
							uni.showToast({
								title: result.msg,
								icon: 'error'
							})
						}
					},
					complete() {
						uni.hideLoading()
					}
				});
			},
			getGonggao(){
				var that = this
				uni.request({
					url: this.global.url+'api/zy/notice_detail',
					method: 'POST',
					data: {
						id: that.id
					},
					success: (res) => {
						let result = res.data
						if (result.code == 1) {
							console.log(result.data.title)
							uni.setNavigationBarTitle({
								title: result.data.title
							});
							that.title = result.data.title
							var data = result.data.content
							data = data.replace(/<img/gi, "<img class='richImg'");
							that.data = data
						} else {
							uni.showToast({
								title: result.msg,
								icon: 'error'
							})
						}
					},
					complete() {
						uni.hideLoading()
					}
				});
			},
			getList(){
				var that = this
				uni.request({
					url: this.global.url+'api/zy/article_detail',
					method: 'POST',
					data: {
						id: that.id
					},
					success: (res) => {
						let result = res.data
						if (result.code == 1) {
							uni.setNavigationBarTitle({
								title: result.data.name
							});
							that.title = result.data.name
							var data = result.data.content
							data = data.replace(/<img/gi, "<img class='richImg'");
							that.data = data
						} else {
							uni.showToast({
								title: result.msg,
								icon: 'error'
							})
						}
					},
					complete() {
						uni.hideLoading()
					}
				});
			},
		}
	}
</script>

<style>
	.richImg {
	    width: 100% !important;
	    height: auto !important;
	}
</style>
